<?php 
include_once 'z_header.php';
include_once '../action/lcbController.php';
if(!isset($_SESSION['nip'])){
    header('location:login.php');
}?>
<div class="container">  
    <div class="row">

<?php if(isset($_GET['view'])){
if(isset($error))echo $error;
?>
<div class="span12 pull-left accordion-group">
<table class="table table-bordered"> 
    <fieldset>  
        <legend><div class="pull-left">&nbsp;REFERENSI LIBUR DAN CUTI BERSAMA</div>
                 <?php if($_SESSION['admin']=='Y'){ ?>
                    <div class="pull-right"><a href="pengaturan.lcb.php?rekam" class="btn btn-primary">Rekam Baru</a>&nbsp &nbsp;</div> 
              <?php } ?>
        </legend>
        <thead>  
          <tr>  
            <th>Tanggal</th>  
            <th>Keterangan</th>
            <th>Jenis Libur</th>
    <?php if($_SESSION['admin']=='Y'){ ?>
            <th>Pengaturan</th>
    <?php } ?>
          </tr>  
        </thead>  
        <tbody> 
         <?php 
            if($data_lcb!=NULL){
                foreach($data_lcb as $lcb){
            ?>
             
          <tr>  
            <td><?php echo $lcb->tgl_lcb; ?></td> 
            <td><?php echo $lcb->ket_lcb; ?></td>
            <td><?php if($lcb->jns_lcb=='L'){
                            echo "Libur Nasional";
                      }else{
                            echo "Cuti Bersama";
                      }?>
            </td>
                <?php $status=explode(",",$lcb->status_lcb); ?>
             <?php if($_SESSION['admin']=="Y"){ ?>
            <td>
                <?php if($status[0]==1){ ?>              
                <form method="post" action="">
                <a href="?ubah&id=<?php echo $lcb->id_lcb; ?>"><button type="button" class="btn btn-warning"><i class="icon-edit" align="center" ></i> Ubah</button></a> &nbsp
                <a href="?hapus&id=<?php echo $lcb->id_lcb;?>" data-confirm="Anda yakin Akan menghapus data libur <?php echo $lcb->ket_lcb.' tanggal '.$lcb->tgl_lcb; ?> ?" <button class="btn btn-danger"><i class="icon-remove"></i>Hapus</button></a>
                <input type="hidden" name="id_lcb" value="<?php echo $lcb->id_lcb;?>">
                <input type="hidden" name="jns_lcb" value="<?php echo $lcb->jns_lcb;?>">
                <input type="hidden" name="tgl_lcb" value="<?php echo $lcb->tgl_lcb;?>">
                <input type="hidden" name="ket_lcb" value="<?php echo $lcb->ket_lcb;?>">
                <input type="submit" class="btn btn-primary" id="setujui_lcb" name="setujui_lcb" value="Update">
                </form>
                <?php }else{
                    echo '<strong>SUDAH DIUPDATE</strong>';
                } ?>
            </td>
             <?php } ?>
          </tr> 
          
                <?php } 
            }?>   
        </tbody>  
      </table>
      </fieldset>
</div>
<?php } ?>

<!--AWAL FORM REKAM LIBUR DAN CUTI BERSAMA-->
<?php 
if(isset($_GET['rekam'])){ ?>
<script>
$(function() {
$( "#tgl_lcb" ).datepicker();
});
</script>
<div class="span6 offset3 accordion-group">
    <div class="span5">
    <form class="form-horizontal" method="post" action="" id="form_rekam_lcb">  
            <fieldset>  
                <legend>Rekam Libur dan Cuti Bersama</legend>  
                <div class="control-group">  
                    <label class="control-label" for="tgl_lcb">Tanggal</label>  
                        <div class="controls">  
                            <input type="text" class="input-medium" name="tgl_lcb" id="tgl_lcb">
                        </div>  
                </div> 

                <div class="control-group">  
                    <label class="control-label" for="ket_lcb">Keterangan </label>  
                        <div class="controls">  
                            <textarea row="3" name="ket_lcb" id="ket_lcb"></textarea>
                        </div>  
                </div> 

                <div class="control-group">  
                    <label class="control-label" for="jns_lcb">Jenis Libur/Cuti Bersama </label>  
                        <div class="controls">
                            <select name="jns_lcb" class="input-medium">
                                <option value="L">Libur Nasional</option>
                                <option value="CB">Cuti Bersama</option>
                            </select>
                        </div>
                </div> 
                
                <div class="form-actions"> 
                    <a href="pengaturan.lcb.php?view" class="btn">Batal</a>
                    <button type="submit" class="btn btn-primary" name="simpan_lcb">Simpan</button>  
                </div>

            </fieldset>
    </form>
    </div>
</div>
<?php } ?> <!--AKHIR FORM REKAM LIBUR DAN CUTI BERSAMA-->

<!--AWAL FORM UBAH LIBUR DAN CUTI BERSAMA-->
<?php
if(isset($_GET['ubah'])){ ?>
<div class="span6 offset3 accordion-group">
    <div class="span4">
    <form class="form-horizontal" method="post" action="" id="form_ubah_lcb">  
            <fieldset>  
                <legend>Ubah Libur dan Cuti Bersama</legend>  
                <?php if($ubah_lcb!=NULL){
                    foreach($ubah_lcb as $ubah){?>
                <div class="control-group">  
                    <label class="control-label" for="tgl_lcb">Tanggal Libur</label>  
                        <div class="controls">  
                            <input type="hidden" class="input-medium" name="id_lcb" id="id_lcb" value="<?php echo $ubah->id_lcb; ?>">
                            <input type="text" class="input-medium" name="tgl_lcb" id="tgl_lcb" value="<?php echo $ubah->tgl_lcb; ?>">
                        </div>  
                </div> 

                <div class="control-group">  
                    <label class="control-label" for="ket_lcb">Keterangan Libur </label>  
                        <div class="controls">  
                            <textarea row="3" name="ket_lcb" id="ket_lcb"> <?php echo $ubah->ket_lcb;?></textarea>
                        </div>  
                </div> 

                <div class="control-group">  
                    <label class="control-label" for="jns_lcb">Jenis Libur/Cuti Bersama </label>  
                        <div class="controls">
                            <select name="jns_lcb" class="input-medium">
                                <option value="L" >Libur Nasional</option>
                                <option value="L" >Libur Nasional</option>
                                <option value="CB">Cuti Bersama</option>
                            </select>
                        </div>
                </div> 
                
                <div class="form-actions"> 
                    <a href="pengaturan.lcb.php?view" class="btn">Batal</a>
                    <button type="submit" class="btn btn-primary" name="update_lcb">Simpan</button>  
                </div>
                    <?php }
                } ?>
            </fieldset>
    </form>
    </div>
</div>
    <?php     
            }
    ?> <!--AKHIR FORM UBAH LIBUR DAN CUTI BERSAMA-->
<script>
jQuery(function(){
        $('a[data-confirm]').click(function(ev) {
                                var href = $(this).attr('href');

                                if (!$('#dataConfirmModal').length) {
                                        $('body').append('<div id="dataConfirmModal" class="modal" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h3 id="dataConfirmLabel">Konfirmasi Peghapusan</h3></div><div class="modal-body"></div><div class="modal-footer"><button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Batal</button><a class="btn btn-danger" id="dataConfirmOK">Ya</a></div></div>');
                                }
                                $('#dataConfirmModal').find('.modal-body').text($(this).attr('data-confirm'));
                                $('#dataConfirmOK').attr('href', href);
                                $('#dataConfirmModal').modal({show:true});
                                return false;
                        });
        jQuery("#tgl_lcb").validate({
            expression: "if (VAL) return true; else return false;",
            message: "Tanggal libur harus diisi"
        });
        jQuery("#ket_lcb").validate({
            expression: "if (VAL) return true; else return false;",
            message: "Keterangan libur harus diisi",
        });
            jQuery('.AdvancedForm').validated(function(){
                    alert("Use this call to make AJAX submissions.");
            });
    });
               
</script>    
<?php include_once 'z_footer.php';